<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="学生姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入学生姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班级" prop="classId">
        <el-select v-model="queryParams.classId" placeholder="请选择所在班级">
          <el-option
            v-for="classs in classes"
            :label="classs.name"
            :value="classs.id">
            <span style="float: right; color: #8492a6; font-size: 13px">{{ classs.name }}</span>
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="校区" prop="school">
        <el-select v-model="queryParams.school" placeholder="请选择校区" clearable>
          <el-option
            v-for="dict in dict.type.sys_itsource"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="学生状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择学生状态" clearable>
          <el-option
            v-for="dict in dict.type.sys_student_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="电话" prop="tel">
        <el-input
          v-model="queryParams.tel"
          placeholder="请输入电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['student:student:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['student:student:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['student:student:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['student:student:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-download"
          size="mini"
          @click="updateState"
          v-hasPermi="['student:student:edit']"
        >修改状态</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-download"
          size="mini"
          @click="changeClass"
          v-hasPermi="['student:student:edit']"
        >留级转班</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="stuAddTrack"
          v-hasPermi="['student:teaching:stalke']"
        >添加跟踪</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="studentList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="学生ID" align="center" prop="id" />
      <el-table-column label="学生姓名" align="center" prop="name" />
      <el-table-column label="班级ID" align="center" prop="bblClass.name" />
      <el-table-column label="校区" align="center" prop="school">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_itsource" :value="scope.row.school"/>
        </template>
      </el-table-column>
      <el-table-column label="学生状态" align="center" prop="state">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_student_type" :value="scope.row.state"/>
        </template>
      </el-table-column>
      <el-table-column label="模拟面试" align="center" prop="simulationInterview">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_interview" :value="scope.row.simulationInterview"/>
        </template>
      </el-table-column>
      <el-table-column label="结业考试" align="center" prop="finalTest">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_end_test" :value="scope.row.finalTest"/>
        </template>
      </el-table-column>
      <el-table-column label="电话" align="center" prop="tel" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
<!--          todo-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-share"
            @click="handLetrackRecord(scope.row)"
            v-hasPermi="['teaching:focuson:remove']"
          >跟踪记录</el-button>
<!--          todo-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-suitcase"
            @click="attention(scope.row)"
            v-hasPermi="['student:student:edit']"
          >关注</el-button>

          <el-button
            size="mini"
            type="text"
            icon="el-icon-picture"
            @click="getThis(scope.row)"
            v-hasPermi="['student:student:query']"
          >详情</el-button>

          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['student:student:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['student:student:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改学生对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="学生姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入学生姓名" />
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-select v-model="form.gender" placeholder="请选择性别">
            <el-option
              v-for="dict in dict.type.sys_user_sex"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input v-model="form.age" placeholder="请输入年龄" />
        </el-form-item>
        <el-form-item label="班级">
          <el-select v-model="form.classId" placeholder="请选择">
            <el-option
              v-for="classs in classes"
              :label="classs.name"
              :value="classs.id">
              <span style="float: right; color: #8492a6; font-size: 13px">{{ classs.name }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="校区" prop="school">
          <el-select v-model="form.school" placeholder="请选择校区">
            <el-option
              v-for="dict in dict.type.sys_itsource"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学生状态" prop="state">
          <el-select v-model="form.state" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.sys_student_type"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模拟面试" prop="simulationInterview">
          <el-select v-model="form.simulationInterview" placeholder="请选择模拟面试">
            <el-option
              v-for="dict in dict.type.sys_interview"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结业考试" prop="finalTest">
          <el-select v-model="form.finalTest" placeholder="请选择结业考试">
            <el-option
              v-for="dict in dict.type.sys_end_test"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="电话" prop="tel">
          <el-input v-model="form.tel" placeholder="请输入电话" />
        </el-form-item>
        <el-form-item label="学历" prop="education">
          <el-input v-model="form.education" placeholder="请输入学历" />
        </el-form-item>
        <el-form-item label="专业" prop="profession">
          <el-input v-model="form.profession" placeholder="请输入专业" />
        </el-form-item>
        <el-form-item label="大学学校" prop="college">
          <el-input v-model="form.college" placeholder="请输入大学学校" />
        </el-form-item>
        <el-form-item label="父母电话" prop="parentTel">
          <el-input v-model="form.parentTel" placeholder="请输入父母电话" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 修改学生状态对话框 -->
    <el-dialog :title="title" :visible.sync="open1" width="500px" append-to-body>
      <el-form ref="form1" :model="form1" :rules="rules" label-width="80px">

        <el-form-item label="学生状态" prop="state">
          <el-select v-model="form1.state" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.sys_student_type"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模拟面试" prop="simulationInterview">
          <el-select v-model="form1.simulationInterview" placeholder="请选择模拟面试">
            <el-option
              v-for="dict in dict.type.sys_interview"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结业考试" prop="finalTest">
          <el-select v-model="form1.finalTest" placeholder="请选择结业考试">
            <el-option
              v-for="dict in dict.type.sys_end_test"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormState">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 留级转班对话框 -->
    <el-dialog :title="title" :visible.sync="open2" width="500px" append-to-body>
      <el-form ref="form2" :model="form2" :rules="rules" label-width="80px">
        <el-form-item label="学生姓名" prop="name" >
          <el-input v-model="form2.name" placeholder="请输入学生姓名" :disabled="true"/>
        </el-form-item>
        <el-form-item label="班级">
          <el-select v-model="form2.classId" placeholder="请选择">
            <el-option
              v-for="classs in classes"
              :label="classs.name"
              :value="classs.id">
              <span style="float: right; color: #8492a6; font-size: 13px">{{ classs.name }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学生状态" prop="state">
          <el-select v-model="form2.state" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.sys_student_type"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="notes">
          <el-input v-model="form2.notes" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitChangeClass">确 定</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 学生详情展示框 -->
    <el-dialog :title="title" :visible.sync="open4" width="500px" append-to-body>
      <el-form ref="form4" :model="form4" :rules="rules" label-width="80px">
        <el-form-item label="学生姓名" prop="name">
          <el-input v-model="form4.name" placeholder="请输入学生姓名" :readonly="true"/>
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-select v-model="form4.gender" placeholder="请选择性别" :readonly="true">
            <el-option
              v-for="dict in dict.type.sys_user_sex"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input v-model="form4.age" placeholder="请输入年龄" :readonly="true"/>
        </el-form-item>
        <el-form-item label="班级">
          <el-select v-model="form4.classId" placeholder="请选择" :readonly="true">
            <el-option
              v-for="classs in classes"
              :label="classs.name"
              :value="classs.id">
              <span style="float: right; color: #8492a6; font-size: 13px">{{ classs.name }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="校区" prop="school">
          <el-select v-model="form4.school" placeholder="请选择校区" :readonly="true">
            <el-option
              v-for="dict in dict.type.sys_itsource"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学生状态" prop="state">
          <el-select v-model="form4.state" placeholder="请选择学生状态" :readonly="true">
            <el-option
              v-for="dict in dict.type.sys_student_type"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模拟面试" prop="simulationInterview">
          <el-select v-model="form4.simulationInterview" placeholder="请选择模拟面试" :readonly="true">
            <el-option
              v-for="dict in dict.type.sys_interview"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结业考试" prop="finalTest">
          <el-select v-model="form4.finalTest" placeholder="请选择结业考试" :readonly="true">
            <el-option
              v-for="dict in dict.type.sys_end_test"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="电话" prop="tel">
          <el-input v-model="form4.tel" placeholder="请输入电话" :readonly="true"/>
        </el-form-item>
        <el-form-item label="学历" prop="education">
          <el-input v-model="form4.education" placeholder="请输入学历" :readonly="true"/>
        </el-form-item>
        <el-form-item label="专业" prop="profession">
          <el-input v-model="form4.profession" placeholder="请输入专业" :readonly="true"/>
        </el-form-item>
        <el-form-item label="大学学校" prop="college">
          <el-input v-model="form4.college" placeholder="请输入大学学校" :readonly="true"/>
        </el-form-item>
        <el-form-item label="父母电话" prop="parentTel">
          <el-input v-model="form4.parentTel" placeholder="请输入父母电话" :readonly="true"/>
        </el-form-item>
        <el-form-item label="备注" prop="notes">
          <el-input v-model="form4.notes" placeholder="暂无备注" :readonly="true"/>
        </el-form-item>
      </el-form>

    </el-dialog>
    <!-- 添加跟踪对话框todo -->
    <el-dialog :title="title" :visible.sync="open3" width="500px" append-to-body>
      <el-form ref="form3" :model="form3" :rules="rules" label-width="80px">
        <el-form-item label="问题类型" prop="impartType" >
          <el-select v-model="form3.impartType" placeholder="请选择问题类型">
            <el-option
              v-for="dict in dict.type.sys_student_question"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发生时间" prop="creationtime">
          <el-date-picker clearable
                          v-model="form3.creationtime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择开班日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="扣除分数" prop="discount">
          <el-input v-model="form3.discount" placeholder="请输入分数" />
        </el-form-item>
        <el-form-item label="负责老师">
          <el-select v-model="form3.teacherId" placeholder="请选择负责老师">
            <el-option
              v-for="teacher in teachers"
              :label="teacher.name"
              :value="teacher.id">
              <span style="float: right; color: #8492a6; font-size: 13px">{{ teacher.name }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="问题描述" prop="remark">
          <el-input v-model="form3.remark" placeholder="请输入问题描述" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitAddStalke">确 定</el-button>
        <el-button @click="cancel3">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 关注对话框todo -->
    <el-dialog :title="title" :visible.sync="open5" width="500px" append-to-body>
      <el-form ref="form5" :model="form5" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form5.name"  placeholder="姓名" :readonly="true"/>
        </el-form-item>
        <el-form-item label="负责老师">
          <el-select v-model="form5.teacherId" placeholder="请选择负责老师">
            <el-option
              v-for="teacher in teachers"
              :label="teacher.name"
              :value="teacher.id">
              <span style="float: right; color: #8492a6; font-size: 13px">{{ teacher.name }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="困难系数" prop="difficulty">
          <el-select v-model="form5.difficulty" placeholder="请选择困难系数">
            <el-option
              v-for="dict in dict.type.sys_difficulty_coefficient"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="加入留级" prop="isRepeate">
        <el-switch
          v-model="isRepeate"
          active-color="#13ce66"
          inactive-color="#ff4949">
        </el-switch>
        </el-form-item>
        <el-form-item label="备注" prop="note">
          <el-input v-model="form5.note" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitAttention">确 定</el-button>
        <el-button @click="cancel5">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 跟踪记录todo -->
    <!-- 跟踪记录 -->
    <el-dialog :title="title" :visible.sync="stalkeFormVisible">
      <el-timeline>
        <el-timeline-item
          v-for="(activity, index) in teachStalke"
          :key="index"
          :color="colors(index)"
          type="primary"
          :timestamp="activity.creationtime"
          placement="top">
          <el-card>
            <h1>跟踪人：{{activity.teachername}}</h1>
            <h3>问题说明：{{activity.remark}} </h3>
          </el-card>
        </el-timeline-item>
      </el-timeline>
      <div slot="footer" class="dialog-footer">
        <el-button @click="stalkeFormVisible = false">关闭</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listStudent, getStudent, delStudent, addStudent, updateStudent,changeClass } from "@/api/student/student";
import {listClass} from "@/api/student/class";
import {addFocusonRepeate} from "@/api/teaching/focuson";
import {listTeacher} from "@/api/teacher/teacher";
import {addStalke , getfindListByStudentId} from "@/api/teaching/stalke";

export default {
  name: "Student",
  dicts: ['sys_student_question','sys_issue_type','sys_difficulty_coefficient','sys_end_test', 'sys_student_type', 'sys_itsource', 'sys_user_sex', 'sys_interview'],
  data() {
    return {
      isRepeate:false,
      //班级
      classes:[],
      //班级
      teachers:[],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生表格数据
      studentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1: false,
      open2: false,
      open3: false,
      open4: false,
      open5: false,
      open6: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        classId: null,
        school: null,
        state: null,
        tel: null,
      },
      // 表单参数
      form: {},
      form1: {
        idss:[],
      },
      form2: {},
      form3: {
        studentsname:null,
        studentId:null,
        teacherId: null,
      },
      form4: {},
      form5: {
        studentId:null,
        interview:null,
        exam:null,
        stuType:null,
        isRepeate: false,
      },
      // 表单校验
      rules: {
      },
      teachStalke:[],
      stalkeFormVisible:false
    };
  },
  created() {
    this.getList();
    this.getClasses();
    this.getTeachers()
  },
  methods: {
    /** 查询班级列表 */
    getClasses() {
      this.loading = true;
      listClass(this.queryParams).then(response => {
        this.classes = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询学生列表 */
    getList() {
      this.loading = true;
      listStudent(this.queryParams).then(response => {
        this.studentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询一个学生详情 */
    getThis(row) {
      this.reset();
      const id = row.id
      getStudent(id).then(response => {
        this.form4 = response.data;
        this.open4 = true;
        this.title = this.form4.name + " 详情";
      });
    },
    /** 查询所有老师列表 */
    getTeachers() {
      this.loading = true;
      listTeacher(this.queryParams).then(response => {
        this.teachers = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    cancel1() {
      this.open1 = false;
      this.reset();
    },
    cancel2() {
      this.open2 = false;
      this.reset();
    },
    cancel3() {
      this.open3 = false;
      this.reset();
    },
    cancel4() {
      this.open4 = false;
      this.reset();
    },
    cancel5() {
      this.open5 = false;
      this.reset();
    },
    cancel6() {
      this.open6 = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        gender: null,
        age: null,
        classId: null,
        school: null,
        state: null,
        simulationInterview: null,
        finalTest: null,
        tel: null,
        education: null,
        profession: null,
        college: null,
        parentTel: null,
        notes: null,
        teacherId: null,
      //  问题跟踪字段
        impartType: null,
        creationtime: null,
        discount: null,
        remark: null,
      //  关注字段todo

      };
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加学生";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getStudent(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改学生";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateStudent(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addStudent(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },

    /** 修改学生状态操作 */
    updateState(row) {
      this.reset();
      let a =row.id || this.ids
      if(a!=0){
        this.open1 = true;
      }
      this.form1.idss = a;
      this.title = "修改学生";
    },
    //修改状态提交按钮
    submitFormState() {
      this.$refs["form1"].validate(valid => {
        if (valid) {
            updateStudent(this.form1).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open1 = false;
              this.getList();
            });
        }
      });
    },

    /** 学生留级转班操作 */
    changeClass(row) {
      this.reset();
      const id = row.id || this.ids
      if (id!=0){
      getStudent(id).then(response => {
        this.form2 = response.data;
        this.open2 = true;
        this.title = this.form2.name + " 转班学生";
      });

    }},
    // 学生留级转班提交按钮
    submitChangeClass() {
      this.$refs["form2"].validate(valid => {
        if (valid) {
          changeClass(this.form2).then(response => {
            this.$modal.msgSuccess("转班成功");
            this.open2 = false;
            this.getList();
          });
        }
      });
    },

    /** 学生跟踪操作todo */
    stuAddTrack(row) {
      this.reset();
      let id = row.id || this.ids
        if (id!=0){
        getStudent(id).then(response => {
          this.form3 = response.data;
          this.open3 = true;
          this.title = this.form3.name + " 添加问题跟踪";
        });

      }},
    // 学生跟踪提交按钮
    submitAddStalke() {
      this.$refs["form3"].validate(valid => {
        if (valid) {
          this.form3.studentId=this.form3.id
          this.form3.studentsname=this.form3.name

          addStalke(this.form3).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open3 = false;
            this.getList();
          });
        }
      });
    },
    /**根据下标选颜色*/
    colors(index){
      if (index % 2 == 0){
        return '00D6FDFF'
      } else {
        return 'D81E1EFF'
      }
    },
    /** 跟踪记录*/
    handLetrackRecord(row){
      let name = row.name
      this.stalkeFormVisible=true;
      this.title = "【"+name+"】的跟踪历史"
      getfindListByStudentId(row.id).then(res => {
        this.teachStalke = res.data
        console.log(JSON.stringify(res.data))
      })
    },
    /** 学生关注操作todo */
    attention(row) {
      this.reset();
      const id = row.id
        getStudent(id).then(response => {
          this.form5 = response.data;
          this.open5 = true;
          this.title = this.form5.name + " 添加关注";
        });

      },
    // 学生关注提交按钮todo
    submitAttention() {
      this.$refs["form5"].validate(valid => {

        if (valid) {
          this.form5.studentId=this.form5.id
          this.form5.interview=this.form5.simulationInterview
          this.form5.exam=this.form5.finalTest
          this.form5.stuType=this.form5.state
          this.form5.isRepeate = this.isRepeate
          console.log(this.form5.isRepeate);
          addFocusonRepeate(this.form5).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open5 = false;
            this.getList();
          });
        }
      });
    },


    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除学生编号为"' + ids + '"的数据项？').then(function() {
        return delStudent(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('student/student/export', {
        ...this.queryParams
      }, `student_${new Date().getTime()}.xlsx`)
    }
  },
  mounted() {
    this.form5.isRepeate = false;
  }
};
</script>
